﻿using System;

namespace Aeon.Framework
{

/// <summary>
/// Value object for custom simple colors.
/// 
/// </summary>
public struct AeonColor : IColor
    {
    // --- Attributes:

    private float r;
    private float g;
    private float b;
    private float a;

    // --- Properties:

    public float R { get { return(r); } set { r = value; } }
    public float G { get { return(g); } set { g = value; } }
    public float B { get { return(b); } set { b = value; } }
    public float A { get { return(a); } set { a = value; } }

    // --- Constructor:

    public AeonColor(float rc, float gc, float bc) : this(rc,gc,bc,1.0f) { }
    public AeonColor(float rc, float gc, float bc, float ac) { r = rc; g = gc; b = bc; a = ac; }

    // --- Comparison:

    private bool compare(IColor obj)
        {
        bool equals;

        if (r == obj.R && g == obj.G && b == obj.B && a == obj.A) equals = true;
        else equals = false;

        return (equals);
        }

    public override int GetHashCode()
        {

        return(r.GetHashCode()^g.GetHashCode()^b.GetHashCode()^a.GetHashCode());
        }

    public override bool Equals(Object obj)
        {
        bool equal = false;

        IColor c = obj as IColor;
        if (c != null) { equal = compare(c); }

        return(equal); 
        }

    public bool Equals(IColor c) 
        {
        bool equal = false;

        if (c is AeonColor && c != null) { equal = compare(c); }

        return(equal);
        }

    }
    
    
}
